package hotel.quartz.oversea.job.meituan;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import hotel.base.oversea.constant.CommonConstants;
import hotel.base.oversea.constant.CommonUrlConstants;
import hotel.base.oversea.constant.quartz.UrlMtEnums;
import hotel.base.oversea.utils.Result;
import hotel.quartz.oversea.job.base.BaseJob;
import hotel.quartz.oversea.util.JobRestTemplateUtils;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;

/**
 * <p>
 *  todo Check Room Price Room Status Log Find Miss Job
 * </p>
 *
 * @description: todo Check Room Price Room Status Log Find Miss Job
 * @author: qiuyy
 * @date: 2020-05-26 13:22
 * @version: V1.0
 */
@Slf4j
public class todoCheckRoomPriceRoomStatusLogFindMissJob implements BaseJob {
    private String timestamp = "Mhoqj"+String.valueOf(System.currentTimeMillis());
    @Autowired
    private RestTemplate restTemplate;
    /**
     *  查询mt_notify_short_log 表 查询没有被推送给第三方携程的  变化数据，钉钉通知
     * @param jobExecutionContext
     */
    @Override
    @SneakyThrows
    public void execute(JobExecutionContext jobExecutionContext) {
        log.info("todo Check Room Price Room Status Log Find Miss Job {} >>>>>>>> 查询没有被推送给第三方携程的变化数据定时器 执行时间: {}",timestamp, DateUtil.now());

        String host = CommonUrlConstants.MEITUAN_HOST;

        String url = host+ UrlMtEnums.findMiss.CHECK_MISS.getValue();
        //发起请求
        Result response = JobRestTemplateUtils.post(url,null,restTemplate);
        if(response.getCode()== CommonConstants.SUCCESS){
            if(!ObjectUtils.isEmpty(response.getData())){
                log.info("todo Check Room Price Room Status Log Find Miss Job {} 查询没有被推送给第三方携程的变化数据定时器  存在遗漏推送第三方携程的变化数据：{}",timestamp, JSON.toJSONString(response));
            }
        }else{
            log.info("todo Check Room Price Room Status Log Find Miss Job {} 查询没有被推送给第三方携程的变化数据定时器  接口调用失败：{}",timestamp, JSON.toJSONString(response));
        }

        log.info("todo Check Room Price Room Status Log Find Miss Job {} >>>>>>>> 查询没有被推送给第三方携程的变化数据定时器 结束时间: {},{}",timestamp, DateUtil.now());
    }

}
